
var city_set_ops = {

    init:function () {

        this.eventBind();
    },

    eventBind:function () {

        $('select').on('change',function () {

            id = $(this).val();

            var data = {

                'id':id
            };

            console.log( data );
            $(this).nextAll('select').remove();

            $.ajax({

                url:"http://127.0.0.1:8999/api/getcity",
                type:"POST",
                dataType:"json",
                data:data,
                success:function (res) {

                    if ( res.code == 200 ){

                        var data = res.data;

                        var sel = $('<select >--请选择--</select>');
                        var ops = '';
                        for ( var i = 0 ; i < data.length;i++){

                            ops +=  '<option value="'+data[i]['id']+'">'+data[i]['name']+'</option>'

                        }
                        sel.html( ops );
                        $('body').append( sel );

                    }

                }

            })



        })

    },

};

$('document').ready( function () {

    city_set_ops.init();

});
